package com.stylefeng.guns.util;

import com.gexin.fastjson.JSON;
import com.gexin.fastjson.JSONObject;
import com.stylefeng.guns.core.common.Tools.CodeMsg;
import com.stylefeng.guns.core.common.Tools.Result;
import com.stylefeng.guns.core.util.ComputerGpsZone;
import com.stylefeng.guns.core.util.HttpUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class UnitTest {
    public static void main(String[] args) {
       String flg="kmcw2018@tty-backMag";
       String mobileServerUrl="http://127.0.0.1:8080/";
       String lineId="00b091a545d645dba4726900c8ed259e";
       String pos="102.77244,25.032504";
       String cityFlg="S";
       String startpos="102.815699,25.033749";
       String endpos="101.689857,26.568394";
        try {
            startpos=java.net.URLDecoder.decode(startpos,"utf-8");
            endpos=java.net.URLDecoder.decode(endpos,"utf-8");
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("lineId",lineId);
            map.put("startpos",startpos);
            map.put("endpos",endpos);
            map.put("sendTime",new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
            String result=HttpUtil.doPost(mobileServerUrl+"gunsApi/auth/orderLine/getPriceKmFromCache",map,"utf-8");
            JSONObject jsonResult=JSON.parseObject(result);
            if(jsonResult.containsKey("code") ){
                if(jsonResult.getIntValue("code")==200){
                    Map<String, String> mapResult = new HashMap<>();
                    mapResult.put("sprice", jsonResult.getJSONObject("data").getString("sprice"));
                    mapResult.put("eprice",  jsonResult.getJSONObject("data").getString("eprice"));
                    mapResult.put("timePrice",  jsonResult.getJSONObject("data").getString("timePrice"));
                    mapResult.put("datePrice",  jsonResult.getJSONObject("data").getString("datePrice"));
                    mapResult.put("kmPrice",  jsonResult.getJSONObject("data").getString("kmPrice"));
                    mapResult.put("km",  jsonResult.getJSONObject("data").getString("km"));

                }else{

                }
            }else {

            }
        }catch(Exception e){
           e.printStackTrace();
        }
       // ComputerGpsZone.isPointInPolygon(lgn,lat,listLng,listLat)
       /*try {
            pos=java.net.URLDecoder.decode(pos,"utf-8");
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("lineId",lineId);
            map.put("pos",pos);
            map.put("cityFlg",cityFlg);
            String result=HttpUtil.doPost(mobileServerUrl+"gunsApi/auth/orderLine/checkPointInCity",map,"utf-8");
            JSONObject jsonResult=JSON.parseObject(result);
            if(jsonResult.containsKey("code")){
                if(jsonResult.getIntValue("code")==200){
                    System.out.println(jsonResult.getJSONObject("data").getString("exists"));
                }else{

                }
            }else {

            }
        }catch(Exception e){
            e.printStackTrace();
        }
        try {
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("flg",flg);
            String result=HttpUtil.doPost(mobileServerUrl+"gunsApi/auth/orderLine/refreshCache",map,"utf-8");
            JSONObject jsonResult=JSON.parseObject(result);
            if(jsonResult.containsKey("code") ){
                if(jsonResult.getIntValue("code")==200){

                }else{

                }
            }else {

            }
        }catch(Exception e){

        }*/

    }
}
